home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / acciap1g / frmopen.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-01  |  12.1 KB  |  309 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
  3. Begin VB.Form FrmOpen 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "#1"
  6.    ClientHeight    =   4200
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   5445
  10.    Icon            =   "FrmOpen.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   4200
  16.    ScaleWidth      =   5445
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   3  'Windows Default
  19.    Begin VB.PictureBox FrmRescent 
  20.       BorderStyle     =   0  'None
  21.       Height          =   2895
  22.       Left            =   360
  23.       ScaleHeight     =   2895
  24.       ScaleWidth      =   4005
  25.       TabIndex        =   2
  26.       Top             =   600
  27.       Width           =   4005
  28.       Begin ComctlLib.ListView LstRecentFiles 
  29.          Height          =   1935
  30.          Left            =   120
  31.          TabIndex        =   5
  32.          Top             =   120
  33.          Width           =   3735
  34.          _ExtentX        =   6588
  35.          _ExtentY        =   3413
  36.          View            =   3
  37.          LabelEdit       =   1
  38.          LabelWrap       =   -1  'True
  39.          HideSelection   =   0   'False
  40.          _Version        =   327682
  41.          Icons           =   "ImageList"
  42.          ForeColor       =   -2147483640
  43.          BackColor       =   -2147483643
  44.          BorderStyle     =   1
  45.          Appearance      =   1
  46.          NumItems        =   2
  47.          BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  48.             Key             =   ""
  49.             Object.Tag             =   ""
  50.             Text            =   "#1"
  51.             Object.Width           =   2540
  52.          EndProperty
  53.          BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
  54.             SubItemIndex    =   1
  55.             Key             =   ""
  56.             Object.Tag             =   ""
  57.             Text            =   "#2"
  58.             Object.Width           =   2540
  59.          EndProperty
  60.       End
  61.       Begin VB.CommandButton CmdCancel 
  62.          Cancel          =   -1  'True
  63.          Caption         =   "CmdCancel"
  64.          Height          =   350
  65.          Left            =   120
  66.          TabIndex        =   4
  67.          Top             =   2520
  68.          Width           =   1120
  69.       End
  70.       Begin VB.CommandButton CmdOpen 
  71.          Caption         =   "CmdOpen"
  72.          Height          =   350
  73.          Left            =   120
  74.          TabIndex        =   3
  75.          Top             =   2160
  76.          Width           =   1120
  77.       End
  78.    End
  79.    Begin VB.PictureBox FrmOpenWindow 
  80.       BorderStyle     =   0  'None
  81.       Height          =   2655
  82.       Left            =   240
  83.       ScaleHeight     =   2655
  84.       ScaleWidth      =   3885
  85.       TabIndex        =   1
  86.       Top             =   600
  87.       Width           =   3885
  88.    End
  89.    Begin ComctlLib.TabStrip TabStrip 
  90.       Height          =   3855
  91.       Left            =   120
  92.       TabIndex        =   0
  93.       Top             =   120
  94.       Width           =   4575
  95.       _ExtentX        =   8070
  96.       _ExtentY        =   6800
  97.       _Version        =   327682
  98.       BeginProperty Tabs {0713E432-850A-101B-AFC0-4210102A8DA7} 
  99.          NumTabs         =   3
  100.          BeginProperty Tab1 {0713F341-850A-101B-AFC0-4210102A8DA7} 
  101.             Caption         =   "#1"
  102.             Key             =   ""
  103.             Object.Tag             =   ""
  104.             ImageVarType    =   2
  105.          EndProperty
  106.          BeginProperty Tab2 {0713F341-850A-101B-AFC0-4210102A8DA7} 
  107.             Caption         =   "#2"
  108.             Key             =   ""
  109.             Object.Tag             =   ""
  110.             ImageVarType    =   2
  111.          EndProperty
  112.          BeginProperty Tab3 {0713F341-850A-101B-AFC0-4210102A8DA7} 
  113.             Caption         =   "#3"
  114.             Key             =   ""
  115.             Object.Tag             =   ""
  116.             ImageVarType    =   2
  117.          EndProperty
  118.       EndProperty
  119.    End
  120.    Begin VB.Timer TmrSetWindow 
  121.       Interval        =   25
  122.       Left            =   4800
  123.       Top             =   120
  124.    End
  125.    Begin ComctlLib.ImageList ImageList 
  126.       Left            =   4800
  127.       Top             =   600
  128.       _ExtentX        =   1005
  129.       _ExtentY        =   1005
  130.       BackColor       =   -2147483643
  131.       ImageWidth      =   32
  132.       ImageHeight     =   32
  133.       MaskColor       =   12632256
  134.       _Version        =   327682
  135.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  136.          NumListImages   =   3
  137.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  138.             Picture         =   "FrmOpen.frx":000C
  139.             Key             =   ""
  140.          EndProperty
  141.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  142.             Picture         =   "FrmOpen.frx":0326
  143.             Key             =   ""
  144.          EndProperty
  145.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  146.             Picture         =   "FrmOpen.frx":0640
  147.             Key             =   ""
  148.          EndProperty
  149.       EndProperty
  150.    End
  151. Attribute VB_Name = "FrmOpen"
  152. Attribute VB_GlobalNameSpace = False
  153. Attribute VB_Creatable = False
  154. Attribute VB_PredeclaredId = True
  155. Attribute VB_Exposed = False
  156. Public AllowClick As Boolean
  157. Private Sub CmdCancel_Click()
  158. Unload Me
  159. End Sub
  160. Private Sub CmdOpen_Click()
  161. On Error Resume Next
  162. Dim Filename As String
  163. Filename = Me.LstRecentFiles.SelectedItem.SubItems(1)
  164. If Err Then
  165.     MsgBox "Please select a item first.", vbCritical
  166. ElseIf Left(Filename, 2) = "::" Then
  167.     DialogRetData = Filename
  168.     Unload Me
  169. ElseIf FileExist(Filename) = False Then
  170.     MsgBox Filename & Chr(10) & "File not found", vbExclamation
  171.     MsgBox Filename
  172.     DialogRetData = Filename
  173.     Unload Me
  174. End If
  175. End Sub
  176. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  177.     Dim i As Integer
  178.     If Shift = vbCtrlMask And KeyCode = vbKeyTab Then
  179.         i = Me.TabStrip.SelectedItem.Index
  180.         If i = Me.TabStrip.Tabs.Count Then
  181.             Set Me.TabStrip.SelectedItem = Me.TabStrip.Tabs(1)
  182.         Else
  183.             Set Me.TabStrip.SelectedItem = Me.TabStrip.Tabs(i + 1)
  184.         End If
  185.     End If
  186. End Sub
  187. Private Sub Form_Load()
  188. 'Get the command captions
  189. Me.TabStrip.Tabs(1).Caption = GetCaption(Tab_New)
  190. Me.TabStrip.Tabs(2).Caption = GetCaption(Tab_Open)
  191. Me.TabStrip.Tabs(3).Caption = GetCaption(Tab_Recent)
  192. Me.CmdCancel.Caption = GetCaption(Cmd_Cancel)
  193. Me.CmdOpen.Caption = GetCaption(Cmd_Open)
  194. Me.LstRecentFiles.ColumnHeaders(1).Text = GetCaption(LstItm_Name)
  195. Me.LstRecentFiles.ColumnHeaders(2).Text = GetCaption(LstItm_File)
  196. FrmPossDialog.Top = Me.Top + Me.FrmOpenWindow.Top + (-20 * GetTitleBarHeight) 'set the poss of the dialog this makes it less 'flashing'
  197. FrmPossDialog.Left = Me.Left + Me.FrmOpenWindow.Left + 200
  198. Me.TmrSetWindow.Enabled = True 'Enable the 'Open-Window Finder'
  199. Me.Caption = Use_Caption
  200. ' Load the Openwindow, but clips to FrmPossDialog for possition. using the timer
  201. ' Uses the random caption.
  202. Retdata = OpenDialog(FrmPossDialog.hwnd, TempCaption)
  203. If Not Retdata = vbNullString Then DialogRetData = Retdata 'If the user choose to open a file set this to the return
  204. Unload Me 'Done
  205. End Sub
  206. Private Sub Form_Unload(Cancel As Integer)
  207. 'Nothing here, the opendialog is a child, so closed with main window (if still open)
  208. End Sub
  209. Private Sub LstRecentFiles_DblClick()
  210. If AllowClick = True Then 'If the user dblclicked an item it is set to true by LstRecentFiles_MouseDown
  211.     CmdOpen_Click
  212. End If
  213. End Sub
  214. Private Sub LstRecentFiles_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  215. On Error Resume Next
  216. If Not Me.LstRecentFiles.HitTest(x, y).Text = vbNullString Then 'Check if the user clicked an item
  217.     AllowClick = True 'Yes
  218. End If
  219. If Err Then AllowClick = False 'No
  220. End Sub
  221. Private Sub TabStrip_Click()
  222. If Me.TabStrip.Tabs(1).Selected Then
  223.     '
  224.     'Templates
  225.     '
  226.     SetActiveWindow Me.hwnd
  227.     Me.FrmOpenWindow.Visible = False
  228.     Me.FrmRescent.Visible = True
  229.     Me.LstRecentFiles.View = lvwIcon
  230.     Me.LstRecentFiles.ListItems.Clear
  231.     ' Add some items
  232.     Set Mitem = Me.LstRecentFiles.ListItems.Add(, , "Empty Project", 1)
  233.         Mitem.SubItems(1) = "::New"
  234.     Set Mitem = Me.LstRecentFiles.ListItems.Add(, , "Example Project 1", 2)
  235.         Mitem.SubItems(1) = "::Sample1"
  236.     Set Mitem = Me.LstRecentFiles.ListItems.Add(, , "Example Project 2", 3)
  237.         Mitem.SubItems(1) = "::Sample2"
  238.         
  239.     If Me.LstRecentFiles.ListItems.Count > 0 Then 'Select an item in the list, looks nicer
  240.         Me.LstRecentFiles.ListItems(1).Selected = True
  241.     End If
  242.         
  243. ElseIf Me.TabStrip.Tabs(2).Selected Then
  244.     '
  245.     'Open File
  246.     '
  247.     'Drawn at startup
  248.     '
  249.     Me.FrmOpenWindow.Visible = True
  250.     Me.FrmRescent.Visible = False
  251. ElseIf Me.TabStrip.Tabs(3).Selected Then
  252.     '
  253.     'RecentFiles
  254.     '
  255.     Me.FrmOpenWindow.Visible = False
  256.     Me.FrmRescent.Visible = True
  257.     Dim Filename As String
  258.     Dim FileCaption As String
  259.     Dim i As Integer
  260.     Me.LstRecentFiles.ListItems.Clear
  261.     Me.LstRecentFiles.View = lvwReport
  262.     For i = 1 To GetRescentFiles(vbNullString, vbNullString, 0) 'Get the recent files from the registry
  263.         Call GetRescentFiles(Filename, FileCaption, i)
  264.         Set Mitem = Me.LstRecentFiles.ListItems.Add(, , FileCaption)
  265.             Mitem.SubItems(1) = Filename
  266.     Next
  267.     If Me.LstRecentFiles.ListItems.Count > 0 Then 'Select an item in the list, looks nicer
  268.         Me.LstRecentFiles.ListItems(1).Selected = True
  269.     End If
  270. End If
  271. End Sub
  272. Private Sub TmrSetWindow_Timer()
  273. Dim OpdlghWnd As Long 'Variable for OpenDialogs hWnd
  274. OpdlghWnd = FindWindow(vbNullString, TempCaption) 'Search the window
  275. If OpdlghWnd <> 0 Then 'Must been creaded, just i case...
  276.     Me.TmrSetWindow.Enabled = False 'Turn off the timer function, only once
  277.     Dim TmpRec As RECT 'Use to repossion the dialog
  278.     SetParent OpdlghWnd, Me.FrmOpenWindow.hwnd 'Make it as a child in the Picture box
  279.     GetWindowRect OpdlghWnd, TmpRec 'Get the size of the window
  280.     SetWindowPos OpdlghWnd, 0, -4, -1 * TitleBarHeight, TmpRec.Right - TmpRec.Left, TmpRec.Bottom - TmpRec.Top, 0 'Make the window in top of the box and cover the outher lines
  281.     FrmOpenWindow.Move 260, 525, Screen.TwipsPerPixelY * (TmpRec.Right - TmpRec.Left - (2 * BorderY)), Screen.TwipsPerPixelX * (TmpRec.Bottom - TmpRec.Top - TitleBarHeight - (2 * BorderX)) 'Make the picture box the correct size
  282.         
  283.     Me.TabStrip.Width = Me.FrmOpenWindow.Width + 300 'Make tabpage the correct size
  284.     Me.TabStrip.Height = Me.FrmOpenWindow.Height + 600
  285.     Me.Height = Me.FrmOpenWindow.Height + 1220 'Make form the correct size
  286.     Me.Width = Me.FrmOpenWindow.Width + 650
  287.     Me.TabStrip.Tabs(2).Selected = True 'Set the tabpage to open
  288.     Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2 'Center on screen
  289.     Me.Visible = True 'Show the work done!
  290.     '
  291.     ' Some work left over to do...
  292.     '
  293.     SetWindowText OpdlghWnd, "Open" 'Write an ordinary caption, Just in case..
  294.     Unload FrmPossDialog 'No longer in use
  295.     DoEvents ' Wait a little
  296.     Me.FrmRescent.Move Me.FrmOpenWindow.Left, Me.FrmOpenWindow.Top, Me.FrmOpenWindow.Width, Me.FrmOpenWindow.Height 'Set the second tabpage
  297.     Me.CmdOpen.Left = Me.FrmRescent.Width - 1325
  298.     Me.CmdOpen.Top = Me.FrmRescent.Height - 855
  299.     Me.CmdCancel.Left = Me.CmdOpen.Left
  300.     Me.CmdCancel.Top = Me.FrmRescent.Height - 425
  301.     Me.LstRecentFiles.Width = Me.TabStrip.Width - 500
  302.     Me.LstRecentFiles.Height = Me.TabStrip.Height - 1700
  303.     Me.LstRecentFiles.ColumnHeaders(2).Width = Me.LstRecentFiles.Width - Me.LstRecentFiles.ColumnHeaders(1).Width - 620
  304.     DoEvents
  305.     'Last, but not least. Setting the focus so keyboard input can be used, in case there is no mouse!
  306.     SetActiveWindow OpdlghWnd
  307. End If
  308. End Sub
  309.